package com.meitianhui.convenitenbuy.module.mine.adapter;

import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.meitianhui.convenitenbuy.R;
import com.meitianhui.convenitenbuy.module.mine.model.ShopGuiderBean;

import java.util.List;

/**
 * Created by amy on 2017/11/27.
 */

public class ShopGuiderAdapter extends BaseQuickAdapter<ShopGuiderBean.Convient, BaseViewHolder> {
    String type;

    public ShopGuiderAdapter(@Nullable List<ShopGuiderBean.Convient> data, String type) {
        super(R.layout.item_shop_guider, data);
        this.type = type;
    }

    @Override
    protected void convert(BaseViewHolder helper, ShopGuiderBean.Convient item) {
        helper.setText(R.id.tv_item_guider_name, item.getStores_name());
        helper.setText(R.id.tv_item_guider_phone, item.getContact_tel());
        helper.setText(R.id.tv_item_guider_address, item.getAddress());


            //解除绑定按钮
            helper.getView(R.id.tv_item_guider_unbind).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (mOnClickButtonListener != null){

                        mOnClickButtonListener.clickBindOrUnbind(helper.getPosition());
                    }
                }
            });
         /*else {
            //绑定按钮
            helper.getView(R.id.tv_item_guider_unbind).setVisibility(View.GONE);
            helper.getView(R.id.tv_item_guider_bind).setVisibility(View.VISIBLE);
            helper.getView(R.id.tv_item_guider_bind).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (mOnClickButtonListener != null){

                        mOnClickButtonListener.clickBindOrUnbind(helper.getPosition());
                    }
                }
            });
        }*/

    }

    public interface OnClickButtonListener {
        void clickBindOrUnbind(int position);
    }

    private OnClickButtonListener mOnClickButtonListener;

    public void setOnClickButtonListener(OnClickButtonListener listener) {
        this.mOnClickButtonListener = listener;
    }

}
